package com.whale.mapper;

import com.github.pagehelper.Page;
import com.whale.dto.OrdersPageQueryDTO;
import com.whale.dto.ReservePageQueryDTO;
import com.whale.entity.Orders;
import com.whale.entity.Reserve;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ReserveMapper {


    /**
     * 插入预约
     * @param reserve
     */
    void insert(Reserve reserve);


    /**
     * 根据预约号查询预约
     * @param reserveNumber
     */
    @Select("select * from reserve where number = #{reserveNumber}")
    Reserve getByNumber(String reserveNumber);

    /**
     * 修改预约信息
     * @param reserve
     */
    void update(Reserve reserve);

    /**
     * 分页条件查询并按下单时间排序
     * @param reservePageQueryDTO
     */
    Page<Reserve> pageQuery(ReservePageQueryDTO reservePageQueryDTO);

    /**
     * 根据id查询预约
     * @param id
     */
    @Select("select * from reserve where id=#{id}")
    Reserve getById(Long id);


    /**
     * 根据预约状态查询预约
     * @param status
     * @param time
     * @return
     */

    @Select("select * from reserve where reserve_time<#{time} and status=#{status}")
    List<Reserve> getByStatusAndReserveTimeLT(Integer status, LocalDateTime time);


}
